package com.honey.compilation.sql;

import java.util.ArrayList;
import java.util.List;

import com.honey.core.builder.CharacterBuilder;
import com.honey.core.builder.CharacterBuilderFactory;
import com.honey.core.utils.StringUtility;

public class ValueElement extends SqlElement{
	
	private String value;
	
	public ValueElement(String value){
		this.value =  value;
	}
	
	public String getValue() {
		return value;
	}
	
	public void setValue(String value) {
		this.value = value;
	}

	/**
	 * 不支持注释
	 */
	public List<String> getSqlDocLines() {
		return new ArrayList<String>();
    }
	/**
	 * 不支持注释
	 */
	public void addSqlDocLine(String ...sqlDocLines) {
		
	}
	
	@Override
	public CharacterBuilder compiledContent(int indentLevel) {
		CharacterBuilder answer = CharacterBuilderFactory.createC8StringBuilder();
		if(StringUtility.stringHasValue(value)){
			answer.append(value)
			.append(SqlKeyWord.OPERATION_SPACE);
		}
		return answer;
	}
	
	
	@Override
	public String toString() {
		return compiledContent(0).toString();
	}
	
	@Override
	public boolean equals(Object obj) {
		if( obj instanceof ValueElement ){
			ValueElement ve = (ValueElement)obj ;
			return this.value.equals( ve .getValue() );
		}else{
			return super.equals(obj);
		}
	}

	@Override
	public int hashCode() {
		return value.hashCode();
	}
	
	
}
